package com.song.html;

import org.armedbear.lisp.Fixnum;
import org.armedbear.lisp.Function;
import org.armedbear.lisp.Interpreter;
import org.armedbear.lisp.JavaObject;
import org.armedbear.lisp.LispObject;
import org.armedbear.lisp.MacroObject;
import org.armedbear.lisp.Packages;
import org.armedbear.lisp.Symbol;
import org.armedbear.lisp.SymbolMacro;

public class Main{
	public static void main(String[] argv){
		try{
			long btime = System.currentTimeMillis();
			Main thisObject= new Main();
			System.out.println("Main:"+(System.currentTimeMillis()-btime));
			Interpreter interpreter= Interpreter.createInstance();
			System.out.println("Interpreter:"+(System.currentTimeMillis()-btime));
			interpreter.eval("(load \"test.lisp\")");
			System.out.println("Load:"+(System.currentTimeMillis()-btime));
    // the function is not in a separate package, thus the43            
	// correct package is CL-USER. Symbol names are44              
	// upper case. Package needs the prefix, because java45               
	// also has a class named Package.46               
			//org.armedbear.lisp.Package defaultPackage= 	Packages.findPackage("CL-USER");
			//System.out.println("DefPackage:"+(System.currentTimeMillis()-btime));
			//Symbol voidsym=	defaultPackage.findExternalSymbol("run-fun-1");
			LispObject lo = interpreter.eval("(run-fun-1 add :a 1 :b 2)");
			
			//LispObject mlist = defaultPackage.findSymbol("run-fun-1");
			//LispObject lo = mlist.execute(new Symbol("add"));
			//System.out.println("Find Symbol:"+(System.currentTimeMillis()-btime));
			//SymbolMacro voidFunction= (SymbolMacro) voidsym.getSymbolMacro();
			//System.out.println("voidFunction:"+(System.currentTimeMillis()-btime));
//			LispObject lo = voidFunction.execute(Fixnum.getInstance(1),	
//					Fixnum.getInstance(2),
//					Fixnum.getInstance(3));
			
			//LispObject lo = voidFunction.execute(add);
			
			
			System.out.println("execute:"+(System.currentTimeMillis()-btime));
			System.out.println(lo.toString());
		}catch (Throwable t){            
			System.out.println("exception!");
			t.printStackTrace();
		}   
	}
  
	public int addTwoNumbers(int a, int b)
   {
       return a+ b;
   }
}


